<template>
	<view class="container">
		<!-- <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item>
				<view class="swiper-item"></view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item"></view>
			</swiper-item>
		</swiper> -->
		<view class="swiper">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000"
				indicator-active-color="pink" style="height: 800rpx">
				<swiper-item v-for="item in swiperImageList">
					<view class="swiper-item">
						<!-- uimage -->

						<!-- 注意：单双引号拼接 原则：外双内单 "''+''"  就近原则 会寻找最近的相同引号-->
						<image :src="item.iurl" mode=""></image>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<view class="content">
			<!-- view*3 -->

			<view>Welcome to</view>
			<view>奶茶点餐</view>
			<view>源自你的美</view>
		</view>
		<view class="btn">
			<button @click="toLoginPage">登录</button>
			<button @click="toRegisterPage">注册</button>
		</view>


	</view>
</template>

<script>
	import {
		queryImageByType
	} from "@/api/index";
	export default {
		data() {
			return {
				swiperImageList: []
			}
		},
		onLoad() {
			this.getBannerList()
		},
		methods: {
			//定义获取轮播API接口方法
			getBannerList() {

				queryImageByType(1).then(res => {
					console.log(res.data)
					this.swiperImageList = res.data
				})
			},
			toLoginPage() {
				uni.navigateTo({
					// url: "/pages/login/login"
					url: "/pages/login/login"
				})
			},
			toRegisterPage() {
				uni.navigateTo({
					// url: "/pages/register/register"
					url: "/pages/register/register"
				})
			}
		},

	}
</script>

<style scoped>
	.swiper-item {
		height: 100%;
	}

	.swiper-item image {
		width: 100%;
		height: 100%;
	}

	.content {
		padding: 30rpx;
		/* 元素的总高度和宽度包含内边距和边框(padding 与 border) : */
		box-sizing: border-box;
	}

	/* :nth-child(1) 优点  不需要额外定义class类或id类 */
	.content view:nth-child(1),
	.content view:nth-child(3) {
		font-weight: bold;
		font-size: 30rpx;
		color: #48647a;
	}

	.content view:nth-child(2) {
		color: #fe8787;
		font-size: 56rpx;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}

	.btn button {
		width: 80%;
		font-weight: bold;
		border-radius: 10px;
	}

	.btn button:nth-child(1) {
		background: #fe8787;
		color: #fff;
	}

	.btn button:nth-child(2) {
		margin-top: 20rpx;
		background: #ffe8e8;
		color: #fe8787;
	}
</style>